package enums;

/**
 * 响应状态
 * */
public enum ApiStatus {
	/**提交成功*/
    Ok(200, "Ok"),
	/**消息错误*/
    BadRequest(400, "BadRequest"),
	/**未经授权*/
    Unauthorised(401, "Unauthorised"),
	/**需要付款*/
    PaymentRequired(402, "PaymentRequired"),
	/**不支持的短信通道*/
    Forbidden(403, "Forbidden"),
	/**未配置短信通道*/
    NoneChannel(404, "NoneChannel"),
	/**不支持的运营商*/
    UnSupportISP(405, "UnSupportISP"),
	/**包含未知号码*/
    UnkonwNumber(406, "UnkonwNumber"),
	/**包含黑名单号码*/
    BlockNumber(407, "BlockNumber"),
	/**不支持的地区号码*/
    UnSupportZone(408, "UnSupportZone"),
	/**不支持发送非模板短信*/
    UnSupportNormalSms(409, "UnSupportNormalSms"),
	/**缺少签名*/
    MissingSign(410, "MissingSign"),
	/**签名未定义*/
    UndefinedSign(411, "UndefinedSign"),
	/**稍后重试*/
    ReTryLater(500, "ReTryLater"),
	/**模板不存在*/
    NoTemplateExists(501, "NoTemplateExists");
	
	ApiStatus(int code, String value) {
		this.code = code;
		this.value = value;
	}
	
	private String value;
	private int code;
	
	public String getValue() {
        return value;
    }

    public int getCode() {
        return code;
    }
    
    public static ApiStatus codeOf(int code) {
    	System.out.println("code = " + code);
		for(ApiStatus apiStatus : values()) {
			if(apiStatus.getCode() == code) {
				return apiStatus;
			}
		}
		throw new RuntimeException("code = " + code + " 没有找到对应的枚举");
	}
}
